#ifndef CS1237_DEV_H
#define CS1237_DEV_H

#ifdef __cplusplus
extern "C"
{
#endif

#include "stdint.h"

	typedef struct
	{
		void (*sck_out)(uint8_t out);
		void (*dat_out)(uint8_t out);
		void (*dat_dir)(uint8_t out_or_in); 
		uint8_t (*dat_in)(void);
	} cs1237_hal_type;

	typedef struct
	{
		uint8_t st;			
		uint8_t bits;		
		uint8_t cfg_ext;	
		uint8_t b_ad_ready; 
		int32_t ad_offset;	
		uint16_t TimeCnt;	

		uint8_t buff_index; 
		uint8_t cfg_read;	
		int32_t ad_val;
		int32_t ad_real;
		int32_t ad_org;

		int32_t ad_buff[5];
		uint32_t sample_ok_cnt;

		const cs1237_hal_type *hal;
	} cs1237_type;

	uint8_t cs1237_cfg_set(cs1237_type *obj, uint8_t cmd);

	uint8_t cs1237_cfg_read(cs1237_type *obj);

	uint8_t cs1237_ad_read(cs1237_type *obj);

	uint8_t cs1237_ad_read_and_set(cs1237_type *obj, uint8_t cmd);

#ifdef __cplusplus
}
#endif

#endif 
